package hn.sigit.util.converter;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;

public abstract class EnumConverter<E extends Enum<?>> implements Converter {

	@Override
	public abstract E getAsObject(FacesContext context, UIComponent component,
			String value);

	@SuppressWarnings("unchecked")
	@Override
	public String getAsString(FacesContext context, UIComponent component,
			Object value) {
		if (value == null) return "";
		
		return ((E) value).name();
	}

}
